<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简易ATM</title>
</head>
<body>
    <script>
        let balance = 100;
        let operation;
        do {
            operation = prompt(`请输入您要的操作:
1.存钱
2.取钱
3.显示余额
4.退出`);
            operation = parseInt(operation);
            switch (operation) {
                case 1:
                    let deposit = prompt("请输入存钱金额");
                    deposit = parseFloat(deposit);
                    balance += deposit;
                    alert(`余额：${balance}`);
                    break;
                case 2:
                    let withdraw = prompt("请输入取钱金额");
                    withdraw = parseFloat(withdraw);
                    if (withdraw <= balance) {
                        balance -= withdraw;
                        alert(`余额：${balance}`);
                    } else {
                        alert("余额不足");
                    }
                    break;
                case 3:
                    alert(`余额：${balance}`);
                    break;
                case 4:
                    alert("退出成功");
                    break;
                default:
                    alert("输入错误选项");
            }
        } while (operation !== 4);
    </script>
</body>
</html>